# 所有分区信息列表（包含主分区和子分区）
all_zones = [
    # 动画分区
    {"tid": 1, "code": "douga", "name": "动画"},
    {"tid": 24, "code": "mad", "name": "MAD·AMV"},
    {"tid": 25, "code": "mmd", "name": "MMD·3D"},
    {"tid": 47, "code": "handdrawn", "name": "同人·手书"},
    {"tid": 257, "code": "voice", "name": "配音"},
    {"tid": 210, "code": "garage_kit", "name": "手办·模玩"},
    {"tid": 86, "code": "tokusatsu", "name": "特摄"},
    {"tid": 253, "code": "acgntalks", "name": "动漫杂谈"},
    {"tid": 27, "code": "other", "name": "综合"},
    # 番剧分区
    {"tid": 13, "code": "anime", "name": "番剧"},
    {"tid": 51, "code": "information", "name": "资讯"},
    {"tid": 152, "code": "offical", "name": "官方延伸"},
    {"tid": 32, "code": "finish", "name": "完结动画"},
    {"tid": 33, "code": "serial", "name": "连载动画"},
    # 国创分区
    {"tid": 167, "code": "guochuang", "name": "国创"},
    {"tid": 153, "code": "chinese", "name": "国产动画"},
    {"tid": 168, "code": "original", "name": "国产原创相关"},
    {"tid": 169, "code": "puppetry", "name": "布袋戏"},
    {"tid": 170, "code": "information", "name": "资讯"},
    {"tid": 195, "code": "motioncomic", "name": "动态漫·广播剧"},
    # 音乐分区
    {"tid": 3, "code": "music", "name": "音乐"},
    {"tid": 28, "code": "original", "name": "原创音乐"},
    {"tid": 29, "code": "live", "name": "音乐现场"},
    {"tid": 31, "code": "cover", "name": "翻唱"},
    {"tid": 59, "code": "perform", "name": "演奏"},
    {"tid": 243, "code": "commentary", "name": "乐评盘点"},
    {"tid": 30, "code": "vocaloid", "name": "VOCALOID·UTAU"},
    {"tid": 193, "code": "mv", "name": "MV"},
    {"tid": 266, "code": "fan_videos", "name": "音乐粉丝饭拍"},
    {"tid": 265, "code": "ai_music", "name": "AI音乐"},
    {"tid": 267, "code": "radio", "name": "电台"},
    {"tid": 244, "code": "tutorial", "name": "音乐教学"},
    {"tid": 130, "code": "other", "name": "音乐综合"},
    # 舞蹈分区
    {"tid": 129, "code": "dance", "name": "舞蹈"},
    {"tid": 20, "code": "otaku", "name": "宅舞"},
    {"tid": 198, "code": "hiphop", "name": "街舞"},
    {"tid": 199, "code": "star", "name": "明星舞蹈"},
    {"tid": 200, "code": "china", "name": "国风舞蹈"},
    {"tid": 255, "code": "gestures", "name": "颜值·网红舞"},
    {"tid": 154, "code": "three_d", "name": "舞蹈综合"},
    {"tid": 156, "code": "demo", "name": "舞蹈教程"},
    # 游戏分区
    {"tid": 4, "code": "game", "name": "游戏"},
    {"tid": 17, "code": "stand_alone", "name": "单机游戏"},
    {"tid": 171, "code": "esports", "name": "电子竞技"},
    {"tid": 172, "code": "mobile", "name": "手机游戏"},
    {"tid": 65, "code": "online", "name": "网络游戏"},
    {"tid": 173, "code": "board", "name": "桌游棋牌"},
    {"tid": 121, "code": "gmv", "name": "GMV"},
    {"tid": 136, "code": "music", "name": "音游"},
    {"tid": 19, "code": "mugen", "name": "Mugen"},
    # 知识分区
    {"tid": 36, "code": "knowledge", "name": "知识"},
    {"tid": 201, "code": "science", "name": "科学科普"},
    {"tid": 124, "code": "social_science", "name": "社科·法律·心理"},
    {"tid": 228, "code": "humanity_history", "name": "人文历史"},
    {"tid": 207, "code": "business", "name": "财经商业"},
    {"tid": 208, "code": "campus", "name": "校园学习"},
    {"tid": 209, "code": "career", "name": "职业职场"},
    {"tid": 229, "code": "design", "name": "设计·创意"},
    {"tid": 122, "code": "skill", "name": "野生技术协会"},
    # 科技分区
    {"tid": 188, "code": "tech", "name": "科技"},
    {"tid": 95, "code": "digital", "name": "数码"},
    {"tid": 230, "code": "application", "name": "软件应用"},
    {"tid": 231, "code": "computer_tech", "name": "计算机技术"},
    {"tid": 232, "code": "industry", "name": "科工机械"},
    {"tid": 233, "code": "diy", "name": "极客DIY"},
    # 运动分区
    {"tid": 234, "code": "sports", "name": "运动"},
    {"tid": 235, "code": "basketball", "name": "篮球"},
    {"tid": 249, "code": "football", "name": "足球"},
    {"tid": 164, "code": "aerobics", "name": "健身"},
    {"tid": 236, "code": "athletic", "name": "竞技体育"},
    {"tid": 237, "code": "culture", "name": "运动文化"},
    {"tid": 238, "code": "comprehensive", "name": "运动综合"},
    # 汽车分区
    {"tid": 223, "code": "car", "name": "汽车"},
    {"tid": 258, "code": "knowledge", "name": "汽车知识科普"},
    {"tid": 227, "code": "strategy", "name": "购车攻略"},
    {"tid": 247, "code": "newenergyvehicle", "name": "新能源车"},
    {"tid": 245, "code": "racing", "name": "赛车"},
    {"tid": 246, "code": "modifiedvehicle", "name": "改装玩车"},
    {"tid": 240, "code": "motorcycle", "name": "摩托车"},
    {"tid": 248, "code": "touringcar", "name": "房车"},
    {"tid": 176, "code": "life", "name": "汽车生活"},
    # 生活分区
    {"tid": 160, "code": "life", "name": "生活"},
    {"tid": 138, "code": "funny", "name": "搞笑"},
    {"tid": 254, "code": "parenting", "name": "亲子"},
    {"tid": 250, "code": "travel", "name": "出行"},
    {"tid": 251, "code": "rurallife", "name": "三农"},
    {"tid": 239, "code": "home", "name": "家居房产"},
    {"tid": 161, "code": "handmake", "name": "手工"},
    {"tid": 162, "code": "painting", "name": "绘画"},
    {"tid": 21, "code": "daily", "name": "日常"},
    # 美食分区
    {"tid": 211, "code": "food", "name": "美食"},
    {"tid": 76, "code": "make", "name": "美食制作"},
    {"tid": 212, "code": "detective", "name": "美食侦探"},
    {"tid": 213, "code": "measurement", "name": "美食测评"},
    {"tid": 214, "code": "rural", "name": "田园美食"},
    {"tid": 215, "code": "record", "name": "美食记录"},
    # 动物圈分区
    {"tid": 217, "code": "animal", "name": "动物圈"},
    {"tid": 218, "code": "cat", "name": "喵星人"},
    {"tid": 219, "code": "dog", "name": "汪星人"},
    {"tid": 222, "code": "reptiles", "name": "小宠异宠"},
    {"tid": 221, "code": "wild_animal", "name": "野生动物"},
    {"tid": 220, "code": "second_edition", "name": "动物二创"},
    {"tid": 75, "code": "animal_composite", "name": "动物综合"},
    # 鬼畜分区
    {"tid": 119, "code": "kichiku", "name": "鬼畜"},
    {"tid": 22, "code": "guide", "name": "鬼畜调教"},
    {"tid": 26, "code": "mad", "name": "音MAD"},
    {"tid": 126, "code": "manual_vocaloid", "name": "人力VOCALOID"},
    {"tid": 216, "code": "theatre", "name": "鬼畜剧场"},
    {"tid": 127, "code": "course", "name": "教程演示"},
    # 时尚分区
    {"tid": 155, "code": "fashion", "name": "时尚"},
    {"tid": 157, "code": "makeup", "name": "美妆护肤"},
    {"tid": 252, "code": "cos", "name": "仿妆cos"},
    {"tid": 158, "code": "clothing", "name": "穿搭"},
    {"tid": 159, "code": "catwalk", "name": "时尚潮流"},
    # 资讯分区
    {"tid": 202, "code": "information", "name": "资讯"},
    {"tid": 203, "code": "hotspot", "name": "热点"},
    {"tid": 204, "code": "global", "name": "环球"},
    {"tid": 205, "code": "social", "name": "社会"},
    {"tid": 206, "code": "multiple", "name": "综合"},
    # 娱乐分区
    {"tid": 5, "code": "ent", "name": "娱乐"},
    {"tid": 241, "code": "talker", "name": "娱乐杂谈"},
    {"tid": 262, "code": "cp_recommendation", "name": "CP安利"},
    {"tid": 263, "code": "beauty", "name": "颜值安利"},
    {"tid": 242, "code": "fans", "name": "娱乐粉丝创作"},
    {"tid": 264, "code": "entertainment_news", "name": "娱乐资讯"},
    {"tid": 137, "code": "celebrity", "name": "明星综合"},
    {"tid": 71, "code": "variety", "name": "综艺"},
    # 影视分区
    {"tid": 181, "code": "cinephile", "name": "影视"},
    {"tid": 182, "code": "cinecism", "name": "影视杂谈"},
    {"tid": 183, "code": "montage", "name": "影视剪辑"},
    {"tid": 260, "code": "mashup", "name": "影视整活"},
    {"tid": 259, "code": "ai_imaging", "name": "AI影像"},
    {"tid": 184, "code": "trailer_info", "name": "预告·资讯"},
    {"tid": 85, "code": "shortplay", "name": "小剧场"},
    {"tid": 256, "code": "shortfilm", "name": "短片"},
    {"tid": 261, "code": "comprehensive", "name": "影视综合"},
    # 纪录片分区
    {"tid": 177, "code": "documentary", "name": "纪录片"},
    {"tid": 37, "code": "history", "name": "人文·历史"},
    {"tid": 178, "code": "science", "name": "科学·探索·自然"},
    {"tid": 179, "code": "military", "name": "军事"},
    {"tid": 180, "code": "travel", "name": "社会·美食·旅行"},
    # 电影分区
    {"tid": 23, "code": "movie", "name": "电影"},
    {"tid": 147, "code": "chinese", "name": "华语电影"},
    {"tid": 145, "code": "west", "name": "欧美电影"},
    {"tid": 146, "code": "japan", "name": "日本电影"},
    {"tid": 83, "code": "movie", "name": "其他国家"},
    # 电视剧分区
    {"tid": 11, "code": "tv", "name": "电视剧"},
    {"tid": 185, "code": "mainland", "name": "国产剧"},
    {"tid": 187, "code": "overseas", "name": "海外剧"},
]

# 主分区列表（仅包含各主分区）
main_zones = [
    {"tid": 1, "code": "douga", "name": "动画"},
    {"tid": 13, "code": "anime", "name": "番剧"},
    {"tid": 167, "code": "guochuang", "name": "国创"},
    {"tid": 3, "code": "music", "name": "音乐"},
    {"tid": 129, "code": "dance", "name": "舞蹈"},
    {"tid": 4, "code": "game", "name": "游戏"},
    {"tid": 36, "code": "knowledge", "name": "知识"},
    {"tid": 188, "code": "tech", "name": "科技"},
    {"tid": 234, "code": "sports", "name": "运动"},
    {"tid": 223, "code": "car", "name": "汽车"},
    {"tid": 160, "code": "life", "name": "生活"},
    {"tid": 211, "code": "food", "name": "美食"},
    {"tid": 217, "code": "animal", "name": "动物圈"},
    {"tid": 119, "code": "kichiku", "name": "鬼畜"},
    {"tid": 155, "code": "fashion", "name": "时尚"},
    {"tid": 202, "code": "information", "name": "资讯"},
    {"tid": 5, "code": "ent", "name": "娱乐"},
    {"tid": 181, "code": "cinephile", "name": "影视"},
    {"tid": 177, "code": "documentary", "name": "纪录片"},
    {"tid": 23, "code": "movie", "name": "电影"},
    {"tid": 11, "code": "tv", "name": "电视剧"},
]


# 根据主分区获取子分区
sub_zones_map = {
    1: [24, 25, 47, 257, 210, 86, 253, 27],
    13: [51, 152, 32, 33],
    167: [153, 168, 169, 170, 195],
    3: [28, 29, 31, 59, 243, 30, 193, 266, 265, 267, 244, 130],
    129: [20, 198, 199, 200, 255, 154, 156],
    4: [17, 171, 172, 65, 173, 121, 136, 19],
    36: [201, 124, 228, 207, 208, 209, 229, 122],
    188: [95, 230, 231, 232, 233],
    234: [235, 249, 164, 236, 237, 238],
    223: [258, 227, 247, 245, 246, 240, 248, 176],
    160: [138, 254, 250, 251, 239, 161, 162, 21],
    211: [76, 212, 213, 214, 215],
    217: [218, 219, 222, 221, 220, 75],
    119: [22, 26, 126, 216, 127],
    155: [157, 252, 158, 159],
    202: [203, 204, 205, 206],
    5: [241, 262, 263, 242, 264, 137, 71],
    181: [182, 183, 260, 259, 184, 85, 256, 261],
    177: [37, 178, 179, 180],
    23: [147, 145, 146, 83],
    11: [185, 187],
}

# 根据子分区获取主分区
main_zone_map = {
    24: 1,
    25: 1,
    47: 1,
    257: 1,
    210: 1,
    86: 1,
    253: 1,
    27: 1,
    51: 13,
    152: 13,
    32: 13,
    33: 13,
    153: 167,
    168: 167,
    169: 167,
    170: 167,
    195: 167,
    28: 3,
    29: 3,
    31: 3,
    59: 3,
    243: 3,
    30: 3,
    193: 3,
    266: 3,
    265: 3,
    267: 3,
    244: 3,
    130: 3,
    20: 129,
    198: 129,
    199: 129,
    200: 129,
    255: 129,
    154: 129,
    156: 129,
    17: 4,
    171: 4,
    172: 4,
    65: 4,
    173: 4,
    121: 4,
    136: 4,
    19: 4,
    201: 36,
    124: 36,
    228: 36,
    207: 36,
    208: 36,
    209: 36,
    229: 36,
    122: 36,
    95: 188,
    230: 188,
    231: 188,
    232: 188,
    233: 188,
    235: 234,
    249: 234,
    164: 234,
    236: 234,
    237: 234,
    238: 234,
    258: 223,
    227: 223,
    247: 223,
    245: 223,
    246: 223,
    240: 223,
    248: 223,
    176: 223,
    138: 160,
    254: 160,
    250: 160,
    251: 160,
    239: 160,
    161: 160,
    162: 160,
    21: 160,
    76: 211,
    212: 211,
    213: 211,
    214: 211,
    215: 211,
    218: 217,
    219: 217,
    222: 217,
    221: 217,
    220: 217,
    75: 217,
    22: 119,
    26: 119,
    126: 119,
    216: 119,
    127: 119,
    157: 155,
    252: 155,
    158: 155,
    159: 155,
    203: 202,
    204: 202,
    205: 202,
    206: 202,
    241: 5,
    262: 5,
    263: 5,
    242: 5,
    264: 5,
    137: 5,
    71: 5,
    182: 181,
    183: 181,
    260: 181,
    259: 181,
    184: 181,
    85: 181,
    256: 181,
    261: 181,
    37: 177,
    178: 177,
    179: 177,
    180: 177,
    147: 23,
    145: 23,
    146: 23,
    83: 23,
    185: 11,
    187: 11,
}

# 需要爬取的主分区
required_main_zones = [
    1,
    3,
    129,
    4,
    36,
    188,
    234,
    223,
    160,
    211,
    217,
    119,
    155,
    202,
    5,
    181,
]

if __name__ == "__main__":
    zones_dict = {zone["tid"]: zone for zone in all_zones}

    for tid in required_main_zones:
        # print(f"main_tid: {tid}")
        print(f"{zones_dict[tid]['tid']}\t{zones_dict[tid]['name']}")
        sub_zones = sub_zones_map[tid]
        for sub_tid in sub_zones:
            # print(f"\tsub_tid: {sub_tid}")
            print(f"\t{zones_dict[sub_tid]['tid']}\t{zones_dict[sub_tid]['name']}")

    pass
